<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子38-JS进阶（二）</title>
    </head>

    <body>
        <pre>
            <code>
                    // 例子38

                    var person = {}

                    Object.defineProperties(person, {
                        name: {
                            value: 'Jake',
                            configurable: true
                        },
                        age: {
                            get: function() {
                                return this.value || 22
                            },
                            set: function(value) {
                                this.value = value
                            }
                        }
                    })

                    person.name   // Jake
                    person.age    // 22

            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/38.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>

</html>